<style>
html,
body,
#app,
.divBody {
  height: 100%;
}
.el-header {
  background-color: #b3c0d1;
  color: #333;
  line-height: 60px;
}

.el-aside {
  color: #333;
}
.el-container{height: 100% !important;}
</style>
<template>
  <div class="divBody">
    <el-container style="height: 500px; border: 1px solid #eee">
      <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
        <el-menu :default-openeds='index' :unique-opened='true' router>
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-message"></i>用户中心
            </template>
            <el-menu-item-group>
              <el-menu-item index="userList">用户列表</el-menu-item>
              <el-menu-item index="addUser">新增用户</el-menu-item>
            </el-menu-item-group>
              <el-menu-item index="updateUser">修改用户</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-menu"></i>商品管理
            </template>
            <el-menu-item-group>
              <el-menu-item index="productList">商品列表</el-menu-item>
              <el-menu-item index="addProduct">新增商品</el-menu-item>
            </el-menu-item-group>
              <el-menu-item index="2-3">修改商品</el-menu-item>
            </el-menu-item-group>
            <el-submenu index="2-4">
              <el-menu-item index="2-4-1">选项4-1</el-menu-item>
            </el-submenu>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-setting"></i>导航三
            </template>
            <el-menu-item-group>
              <el-menu-item index="3-1">选项1</el-menu-item>
              <el-menu-item index="3-2">选项2</el-menu-item>
            </el-menu-item-group>
              <el-menu-item index="3-3">选项3</el-menu-item>
            </el-menu-item-group>
            <el-submenu index="3-4">
              <template slot="title">选项4</template>
              <el-menu-item index="3-4-1">选项4-1</el-menu-item>
            </el-submenu>
          </el-submenu>
        </el-menu>
      </el-aside>

      <el-container>
           <el-header style="text-align: right; font-size: 12px">
      <el-dropdown>
        <i class="el-icon-setting" style="margin-right: 15px">
            {{userName}}
            <!-- {{$store.state.userinfo.userName}} -->
            </i>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item>退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
      <span></span>
    </el-header>
        <router-view></router-view>
      </el-container>
    </el-container>
  </div>
</template>
<script>
    import {mapState} from 'vuex'
export default {
  data(){
    return{
      index:[1]
    }
  },
    computed:{
        //使用辅助函数mapState，获取store的state数据
        ...mapState({
            userName:state =>state.userinfo.userName
        }),
        //获取state的状态值
        // userName(){
        //    return this.$store.state.userinfo.userName
        // }
    },
//   data() {
   
//   }
};
</script>